<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">
		<title>个人中心</title>
		<link href="../../AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="../../AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">
		<link href="../../css/personal.css" rel="stylesheet" type="text/css">
		<link href="../../css/systyle.css" rel="stylesheet" type="text/css">
		<script src="../../AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
		<script src="../../AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
	</head>

	<body>
		<!--头 -->
		<header>
			<article>
				<div class="mt-logo">
					<!--顶部导航条 -->
					<div class="am-container header">
						<ul class="message-l">
					<div class="topMessage">
						<div class="menu-hd" id="indexHeader">
							
						</div>
					</div>
				</ul>
						<ul class="message-r">
							<div class="topMessage home">
								<div class="menu-hd">
									<a href="../index.html" target="_top" class="h">商城首页</a>
								</div>
							</div>
						</ul>
					</div>

					<div class="clear"></div>
				</div>
				</div>
			</article>
		</header>

		<div class="center">
			<div class="col-main">
				<div class="main-wrap">
					<div class="wrap-left">
						<div class="wrap-list">
							<div class="m-user">
								<!--个人资产-->
								<div class="m-userproperty">
									<div class="s-bar">
										<i class="s-icon"></i>个人资产
									</div>
									<p class="m-bill" >
										<!--<span class="m-title">余额</span>-->
										<em class="m-num" style="font-size: 25px;color: red;">￥
											<span id="money" style="font-size: 25px;color: red;">0.00</span>
										</em>
									</p>
								</div>
							</div>
							<div class="box-container-bottom"></div>

							<!--订单 -->
							<div class="m-order">
								<div class="s-bar">
									<i class="s-icon"></i>我的订单
									<a class="i-load-more-item-shadow" href="order.html">全部订单</a>
								</div>
								<ul>
									<li>
										<a href="order.html"><i><img src="../../images/send.png"/></i><span>待发货<em id="send" class="m-num">0</em></span></a>
									</li>
									<li>
										<a href="order.html"><i><img src="../../images/receive.png"/></i><span>待收货<em id="receive" class="m-num">0</em></span></a>
									</li>
									<li>
										<a href="order.html"><i><img src="../../images/comment.png"/></i><span>已完成<em id="finish" class="m-num">0</em></span></a>
									</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
				<!--底部-->
			</div>

			<aside class="menu">
				<ul>
					<li class="person active">
						<a href="index.html">个人中心</a>
					</li>
					<li class="person">
						<a href="#">个人资料</a>
						<ul>
							<li>
								<a href="information.html">信息管理</a>
							</li>
						</ul>
					</li>
					<li class="person">
						<a href="#">我的交易</a>
						<ul>
							<li>
								<a href="order.html">买入订单</a>
							</li>
							<li>
								<a href="sellorder.html">卖出订单</a>
							</li>
						</ul>
					</li>
					<li class="person">
						<a href="#">我的资产</a>
						<ul>
							<li>
								<a href="collection.html">正在出售</a>
							</li>
							<li>
								<a href="upload.html">上传商品</a>
							</li>
						</ul>
					</li>
				</ul>

			</aside>
		</div>
		<!--引导 -->
		<div class="navCir">
			<li>
				<a href="../home/home.html"><i class="am-icon-home "></i>首页</a>
			</li>
			<li>
				<a href="../home/sort.html"><i class="am-icon-list"></i>分类</a>
			</li>
			<li>
				<a href="../home/shopcart.html"><i class="am-icon-shopping-basket"></i>购物车</a>
			</li>
			<li class="active">
				<a href="index.html"><i class="am-icon-user"></i>我的</a>
			</li>
		</div>
		
		
		<script>
			$(function(){
				/*检验用户是否登录*/
				if (getCookie("username") == null || getCookie("userid") == null) {
                    window.location.href="../login.html";
                    return;
			    }else{
			    	$("#indexHeader").append(`
                            <a href="#" target="_top" class="h">您好，${getCookie("username")}</a>
                            <a href="javascript:void(0);" onclick="clearCookie()">退出</a>`
                    );
			    }
			    
			    /*根据userid请求数据*/
			   var userid=getCookie("userid");
			   //个人信息
			   $.ajax({
			   		type:"get",
					url:"/user/info/"+userid,
					success:function(result){
						var money=result.data.money;
						$("#money").text(money);
					}
			   });
			   //个人订单
			   $.ajax({
				   	type:"get",
				   	url:"/orders/selectByBuyerid/"+userid,
				   	success:function(result){
				   		var send=0;
				   		var receive=0;
				   		var finish=0;
				   		var data=result.data;
				   		for(var i=0;i<data.length;i++){
				   			if(data[i].status==0){
				   				send++;
				   			}
				   			if(data[i].status==1){
				   				receive++;
				   			}
				   			if(data[i].status==2){
				   				finish++;
				   			}
				   		}
				   		$("#send").text(send);
				   		$("#receive").text(receive);
				   		$("#finish").text(finish);
				   	}
			   });
			   
			})	
		</script>
	</body>

</html>